﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using NhaThuocOnline.Entities;

namespace NhaThuocOnline.Repositories
{
    public class DieuKienBaoQuanRepository:IDisposable
    {
        QLNhathuocContext context = new QLNhathuocContext();
        public void InsertOrUpdate(DieuKienBaoQuan dkbq)
        {
            if (dkbq.Id == default(int))
            {
                context.DieuKienBaoQuans.Add(dkbq);
            }
            else
            {
                context.Entry(dkbq).State = EntityState.Modified;
            }
        }
        public void Delete(int id)
        {
            DieuKienBaoQuan dkbq = context.DieuKienBaoQuans.Find(id);
            context.DieuKienBaoQuans.Remove(dkbq);
        }
        public void Save()
        {
            context.SaveChanges();
        }
        public void Dispose()
        {
            context.Dispose();
        }
        public DieuKienBaoQuan Find(int id)
        {
            return context.DieuKienBaoQuans.Find(id);
        }
        public IQueryable<DieuKienBaoQuan> GetAll
        {
            get { return context.DieuKienBaoQuans; }
        }
    }
}
